<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
	<title>签到详情window</title>

		<link rel="stylesheet" type="text/css" href="../../css/base.css">
		<link href="../../css/mui.min.css" rel="stylesheet"/>
		<link rel="stylesheet" type="text/css" href="../../css/base.css"/>
		<link rel="stylesheet" href="../../css/api.css">
		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
		<link rel="stylesheet" type="text/css" href="../../css/aui.css">
	<style type="text/css" media="screen">

		.base_right_item{
			padding-right: 5px;
			width: 88px;
			text-align: right;
		}
		.padding-top4 {
				padding-top: 4px;
			}
			.padding-left33 {
				padding-left: 33px
			}
			.user_pic {
				width: 40px;
				height: 40px;
				border-radius: 20px;
				border: 2px solid #fff;
			}
			.aui-tab-item{
				height: 40px;
				line-height: 40px;
				font-size: 16px;
			}
			.info{
				clear: left;
				width: 100%;
				height: 30px;
				line-height: 30px;
				vertical-align: middle;
				text-align: center;
				font-size: 12px;
				background-color: white;
			}
			.redcolor{
				color: #D70000;
			}
			.main{
				margin-top: 66px;
			}
	</style>
</head>
<body style="position: relative;">
	<div class="base_style_color " id='BarAppearance' style="height: 22px;width: 100%;position:fixed; left: 0px;top:0px;">
	</div>
		<div class="base_navigation_bar base_style_color base_navigation_item_bar"  style="float: right;">
			<a class="base_left_item" href="#" onclick="backClick()"> <img class="base_back_icon" src="../../image/icon_jiantou.png" alt=""> </a>
			<span id="signName">签到名称</span>
			<a id="rightBtn" class="base_right_item" href="#" onclick="addSign()">多选</a>
		</div>
		<div class="aui-tab main" id="tab" style="position: fixed;top: 0px;left: 0px;width: 100%;z-index: 100;">
		    <div id="unSign" class="aui-tab-item aui-active" onclick="unSign()">未签到</div>
		    <div id="yiSign" class="aui-tab-item" onclick="yiSign()">已签到</div>
		</div>
		<div id="mainUnSign" style="margin-top: 105px;">
			<div id="weiSignNum" class="mui-table-view info base_grey" hidden="hidden"></div>
			<div id="mainUnSignMain">
				
			</div>
		</div>
		<div id="mainYiSign" style="margin-top: 105px;" hidden="hidden">
			<div id="yiSignNum" class="mui-table-view info base_grey" hidden="hidden"></div>
			<div id="mainYiSignMain">
				
			</div>
		</div>
		<div id="selectMore" style="margin-top: 105px;" hidden="hidden">
			<div id="selectMoreYiqianNum" class="mui-table-view info base_grey" hidden="hidden"></div>
			<div id="selectMoreYiqianMain">
				
			</div>
		</div>
		<div id="selectMoreWeiqian" style="margin-top: 105px;"  hidden="hidden">
             <div id="selectMoreWeiqianNum" class="mui-table-view info base_grey" ></div>
             <div id="selectMoreWeiqianMain">
         <!--  <li class="mui-table-view-cell" onclick="selectStateWeiqian('+item.stuid+')">
						<div class="clearfix" style="line-height: 40px;vertical-align: middle;">
							<img class="user_pic left" src="../../icon/checkbutton_umselectd.png" >
							<span class="base_dark_grey base_content_font left_10 left">李四</span>
							<img id="xiugaiWeiQianStateValue'+item.stuid+'" style="width: 15px;height: 15px;float: right;margin-top: 13px;margin-left: 10px;" src="../../icon/checkbutton_unselectd.png" alt="" >
							<span class="redcolor base_content_font right"> 缺勤 </span>

						</div>
					</li>-->
				
			</div>
		</div>
			
		<div class="signState1">
				<div id="signState1" class="mui-popover mui-popover-action mui-popover-bottom">
				<ul class="mui-table-view">
					<li class="mui-table-view-cell">
						<a href="#" typeid="1" style="color:#222222;">设为缺勤</a>
					</li>
					<li class="mui-table-view-cell">
						<a href="#" typeid="2" style="color:#222222;">设为事假</a>
					</li>
					<li class="mui-table-view-cell">
						<a href="#" typeid="3" style="color:#222222;">设为病假</a>
					</li>
					<li class="mui-table-view-cell">
						<a href="#" typeid="4" style="color:#222222;">设为迟到</a>
					</li>
					<li class="mui-table-view-cell">
						<a href="#" typeid="5" style="color:#222222;">设为早退</a>
					</li>
					<li class="mui-table-view-cell">
						<a href="#" typeid="6" style="color:#222222;">设为已签到</a>
					</li>
				</ul>
				<ul class="mui-table-view">
					<li class="mui-table-view-cell">
						<a href="#signState1" typeid="0" style="color:#222222;"><b>取消</b></a>
					</li>
				</ul>
			</div>
		</div>
		
		<div class="signState2">
				<div id="signState2" class="mui-popover mui-popover-action mui-popover-bottom">
				<ul class="mui-table-view">
					<li class="mui-table-view-cell">
						<a href="#" typeid="1" style="color:#222222;">设为缺勤</a>
					</li>
					<li class="mui-table-view-cell">
						<a href="#" typeid="2" style="color:#222222;">设为事假</a>
					</li>
					<li class="mui-table-view-cell">
						<a href="#" typeid="3" style="color:#222222;">设为病假</a>
					</li>
					<li class="mui-table-view-cell">
						<a href="#" typeid="4" style="color:#222222;">设为迟到</a>
					</li>
					<li class="mui-table-view-cell">
						<a href="#" typeid="5" style="color:#222222;">设为早退</a>
					</li>
					<li class="mui-table-view-cell">
						<a href="#" typeid="6" style="color:#222222;">设为未签到</a>
					</li>
				</ul>
				<ul class="mui-table-view">
					<li class="mui-table-view-cell">
						<a href="#signState2" typeid="0" style="color:#222222;"><b>取消</b></a>
					</li>
				</ul>
			</div>
		</div>

			<div class="noSign" hidden="hidden" id="noData" style="background-color: #f0f0f0;">
			<img src="../../image/icon_img.png" width="60%">
			<p class="font16 top_15 base_dark_grey" >
				暂无数据
			</p>
		</div>
		<div class="loadFailure" hidden="hidden" id="noNet">
			<img src="../../image/icon_img01.png" width="60%">
			<p class="" >
				数据加载失败
			</p>
			<p>
				请检查您的网络
			</p>
			<button type="button"  onclick="loadSignedStates()" class="mui-btn mui-btn-outlined">
				重新加载
			</button>
		</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/timeStampTool.js"></script>
	<script src="../../script/common.js"></script>
<script src="../../script/mui.min.js"></script>
<script type="text/javascript">
    var huile = 0;
    var yiqiandao = []; 
    var weiqiandao = [];
    var isSelectMore = 0;
    var isLeftSelect = 1; 
    // var tmpSelectPerson = [];   //当前选择的单人
    var tmpSelectPersonWei = [];  //当前选择的未签到的学生
    var tmpSelectPersonYi = [];  //当前选择的已签到的
    var haveNoDataWeiqian = 0;   //未签到没有加载下来数据
    var haveNoDataYiqian = 0;   //已签到没有加载下来数据
    var isFirstComing = 1;     //判断是否的第一次进入界面 1为第一次进入 0为不是   (暂时不用了)
    var whiteGou = "";
    var greenGou = "";

    apiready = function(){
    	whiteGou = "../../icon/checkbutton_umselectd.png";
    	greenGou = "../../icon/checkbutton_selectd.png";
    	if (api.pageParam.item.name) {
    	   $('#signName').text(api.pageParam.item.name);
    	}
        ItemTypePoPu1();
        ItemTypePoPu2();
        loadSignedStates();

        $('#BarAppearance').click(function(){
        	$('html,body').animate({scrollTop: '0px'}, 200);
        });  
        keyback();
        sendBuriedNotifi('0', '老师端签到详情页', '191');
     }
     //安卓系统返回键监听
	function keyback() {
		api.addEventListener({
			name : 'keyback'
		}, function(ret, err) {
			backClick();
		});
	}
     function sendBuriedNotifi(busionessid, pagetype, pagetypeid) {
			var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : api.pageParam.sourceurl,
				sourcetitle : api.pageParam.sourcetitle,
				accesspageurl : window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			SendBehaviorTrajectoriesNotifi_Study(data);
		}
     
     
     function loadSignedStates() {
        var url = url_signInfoList;
        var params = {
        	iid : api.pageParam.item.id,
        	jid : $api.getStorage('cfnetppjxid'),
        	page : 1,
        	rows : 10000,
        	 cid : api.pageParam.cid,
			pid : api.pageParam.pid,
        }
        showProgress();
        cfnetppPOST(url, params, true, function(data, status) {
                hideProgress();
                api.refreshHeaderLoadDone();
                if (status == 'success') {
                    $('#noNet').hide();
                    if (data.code == 200) {
                        var dataSource = data.data.data;
                        var total = data.data.total;
                        var pagepernum = data.data.pagepernum;
                        initState(dataSource);
                        // alert(JSON.stringify(dataSource));

                    

                    }else if(data.code == 108){
                    	$('#noData').show();

                       api.toast({
                            msg : '暂无签到详情',
                            duration : 2000,
                            location : 'bottom'
                        });
                    }else if(data.code == 101){
                       api.toast({
                            msg : '参数错误',
                            duration : 2000,
                            location : 'bottom'
                        });
                    }
                } else {
                    $('#noNet').show();
                }
            });
    }
    function initState (data) {
        var str = '';
        yiqiandao = [];
        weiqiandao = [];
        for (var i = 0; i < data.length; i++) {
            var item = data[i];
            if (item.status == 2) {  //已签到
               yiqiandao.push(item);
            }else{  //未签到
            	weiqiandao.push(item);
            }
        }
        if (yiqiandao.length > 0) {
        	haveNoDataYiqian = 1;
        }else{
        	haveNoDataYiqian = 0;
        }
        if (weiqiandao.length > 0) {
        	haveNoDataWeiqian = 1;
        }else{
        	haveNoDataWeiqian = 0;
        }
        if (isLeftSelect == 1){     //在左侧未签到
           if (yiqiandao.length > 1) {   //判断已签到下大于一个学生时,才有 多选
	        	$('#rightBtn').show();
	        }else{
	        	$('#rightBtn').hide();
	        }
	        if (weiqiandao.length > 1) {  //判断未签到下大于一个学生时,才有 多选
	        	$('#rightBtn').show();
	        }else{
	        	$('#rightBtn').hide();
	        }
        }else{                     //在右侧已签到
            if (weiqiandao.length > 1) {  //判断未签到下大于一个学生时,才有 多选
	        	$('#rightBtn').show();
	        }else{
	        	$('#rightBtn').hide();
	        }
	        if (yiqiandao.length > 1) {   //判断已签到下大于一个学生时,才有 多选
	        	$('#rightBtn').show();
	        }else{
	        	$('#rightBtn').hide();
	        }
        }

        initYiqiandao(yiqiandao);
        unqiandao(weiqiandao);

        selectYiqiandao(yiqiandao);//保持住 更改完一次 状态后,原来点击的还在选中状态
        selectWeiqiandao(weiqiandao);//保持住 更改完一次 状态后,原来点击的还在选中状态

      


    }
    function selectWeiqiandao (data) {

    	var str = '<ul class="mui-table-view">';
    	for (var i = 0; i < data.length; i++) {
    		var item = data[i];
    		var status = '';
    		if (item.status == 1) {
                status = "未签到";
    		}else if (item.status == 3) {
                status = "缺勤";
    		}else if (item.status == 4) {
    			status = "事假";
    		}else if (item.status == 5) {
    			status = "病假";
    		}else if (item.status == 6) {
    			status = "迟到";
    		}else if (item.status == 7) {
    			status = "早退";
    		}
    		var imgUrl = "../../icon/checkbutton_unselectd.png";


    		str += '<li class="mui-table-view-cell" onclick="selectStateWeiqian('+item.stuid+')">'+
						'<div class="clearfix" style="line-height: 40px;font-size: 0;">'+
							'<img class="user_pic left" src="'+HeadPortraitIsNull(item.picurl)+'" >'+
							'<span class="base_dark_grey base_content_font left_10 left">'+item.stuname+'</span>'+
							'<img id="xiugaiWeiQianStateValue'+item.stuid+'" style="width: 15px;height: 15px;float: right;margin-top: 13px;margin-left: 10px;" src="'+imgUrl+'" alt="" >'+
							'<span class="redcolor base_content_font right"> '+status+' </span>'+

						'</div>'+
					'</li>';
			
    	}
    	str += '</ul>';
    	$('#selectMoreWeiqianMain').html(str);
    	$('#selectMoreWeiqianNum').show();
    	$('#selectMoreWeiqianNum').text("共"+data.length+"人未签到");	
    }
    function selectYiqiandao (data) {
    	var str = '<ul class="mui-table-view">';
    	for (var i = 0; i < data.length; i++) {
    		var item = data[i];

    		var imgUrl = "../../icon/checkbutton_unselectd.png";


    		str += '<li class="mui-table-view-cell" onclick="selectState('+item.stuid+')">'+
						'<div class="clearfix" style="line-height: 40px;font-size: 0;">'+
							'<img class="user_pic left" src="'+HeadPortraitIsNull(item.picurl)+'" >'+
							'<span class="base_dark_grey base_content_font left_10 left">'+item.stuname+'</span>'+
							'<img id="xiugaiYiQianStateValue'+item.stuid+'" style="width: 15px;height: 15px;float: right;margin-top: 13px;margin-left: 10px;" src="'+imgUrl+'" alt="" >'+
							'<span class=" base_content_font right">  </span>'+

						'</div>'+
					'</li>';
    	}
    	str += '</ul>';
    	$('#selectMoreYiqianMain').html(str);
    	$('#selectMoreYiqianNum').show();
    	$('#selectMoreYiqianNum').text("共"+data.length+"人签到");
    }
    function initYiqiandao(data) {
    	var str = '<ul class="mui-table-view">';
    	for (var i = 0; i < data.length; i++) {
    		var item = data[i];
    		str += '<li class="mui-table-view-cell" onclick="xiugaiYiQianState('+item.stuid+')">'+
					'<div class="clearfix" style="line-height: 40px;">'+
						'<img class="user_pic left" src="'+HeadPortraitIsNull(item.picurl)+'" >'+
						'<span class="base_dark_grey base_content_font left_10 left">'+item.stuname+'</span>'+
						'<span id="xiugaiYiQianStateValue'+item.stuid+'" class="base_content_font right">  </span>'+
					'</div>'+
				'</li>';
    	}
    	str += '</ul>';
    	$('#mainYiSignMain').html(str);
    	$('#yiSignNum').show();
    	$('#yiSignNum').text("共"+data.length+"人签到");
    }
    function unqiandao(data) {
    	var str = '<ul class="mui-table-view">';
    	for (var i = 0; i < data.length; i++) {
    		var item = data[i];
    		var status = '';
    		if (item.status == 1) {
                status = "未签到";
    		}else if (item.status == 3) {
                status = "缺勤";
    		}else if (item.status == 4) {
    			status = "事假";
    		}else if (item.status == 5) {
    			status = "病假";
    		}else if (item.status == 6) {
    			status = "迟到";
    		}else if (item.status == 7) {
    			status = "早退";
    		}
    		str += '<li class="mui-table-view-cell" onclick="xiugaiWeiQianState('+item.stuid+')">'+
					'<div class="clearfix" style="line-height: 40px;">'+
						'<img class="user_pic left" src="'+HeadPortraitIsNull(item.picurl)+'" >'+
						'<span class="base_dark_grey base_content_font left_10 left">'+item.stuname+'</span>'+
						'<span id="xiugaiWeiQianStateValue'+item.stuid+'" class="redcolor base_content_font right"> '+status+' </span></div>'+
				'</li>';
					}
    	str += '</ul>';
    	$('#mainUnSignMain').html(str);
    	$('#weiSignNum').show();
    	$('#weiSignNum').text("共"+data.length+"人未签到");
    }

    function unSign () {
			$('#unSign').addClass("aui-active");
			$('#yiSign').removeClass("aui-active");
			$('#mainUnSign').show();
			$('#mainYiSign').hide();
			$('#selectMore').hide();
			$('#selectMoreWeiqian').hide();
			isLeftSelect = 1;
			isSelectMore = 0;
			// tmpSelectPerson = [];
			$('#rightBtn').text("多选");

			if (weiqiandao.length > 1) {
	        	$('#rightBtn').show();
	        }else{
	        	$('#rightBtn').hide();
	        }
		}
	function yiSign () {
			$('#unSign').removeClass('aui-active');
			$('#yiSign').addClass('aui-active');
			$('#mainUnSign').hide();
			$('#mainYiSign').show();
			$('#selectMore').hide();
			$('#selectMoreWeiqian').hide();
			isLeftSelect = 0;
			isSelectMore = 0;
			// tmpSelectPerson = [];
			$('#rightBtn').text("多选");

			if (yiqiandao.length > 1) {
	        	$('#rightBtn').show();
	        }else{
	        	$('#rightBtn').hide();
	        }
		}
    function isContains(obj, arr) {
		if ($.inArray(obj, arr) != -1) {
			return true;
	}}
	function xiugaiYiQianState(index) {
			tmpSelectPersonYi = [];
			tmpSelectPersonYi.push(index);
			mui('#signState2').popover('toggle');
		}
    function xiugaiWeiQianState(index) {
	    	tmpSelectPersonWei = [];
			tmpSelectPersonWei.push(index);
			mui('#signState1').popover('toggle');
    }
    function selectStateWeiqian(index) {
	    event.stopPropagation();
		if ($.inArray(index, tmpSelectPersonWei) != -1) {
            removeByValue(tmpSelectPersonWei,index);
            $('  #xiugaiWeiQianStateValue'+index).attr('src','../../icon/checkbutton_unselectd.png');
		}else{
			tmpSelectPersonWei.push(index);
			$('  #xiugaiWeiQianStateValue'+index).attr('src','../../icon/checkbutton_selectd.png');
		}
           
	}
	function selectState(index) {
	    event.stopPropagation();
		if ($.inArray(index, tmpSelectPersonYi) != -1) {
            removeByValue(tmpSelectPersonYi,index);
            $(' #selectMoreYiqianMain #xiugaiYiQianStateValue'+index).attr('src','../../icon/checkbutton_unselectd.png');
		}else{
			tmpSelectPersonYi.push(index);
			$(' #selectMoreYiqianMain #xiugaiYiQianStateValue'+index).attr('src','../../icon/checkbutton_selectd.png');
		}
           
	}
	function removeByValue(arr, val) {
		  for(var i=0; i<arr.length; i++) {
		    if(arr[i] == val) {
		      arr.splice(i, 1);
		      break;
		    }
		  }
		}

    function backClick() {
       sendBuriedNotifi('1', '老师端签到详情页', '191')
    	api.sendEvent({
    	    name: 'reloadDataList',
    	});
		api.closeToWin({
	        name: 'TeacherSignMangeWin'
        });
	}
	function addSign() {

    	if (isLeftSelect == 1) {   //左边未签到被点了
            if (haveNoDataWeiqian == 1) {
            	if (isSelectMore == 0) {  //多选被点了
            
				$('#rightBtn').text("修改状态"); 
					isSelectMore = 1;
					// alert("左边多选了");
					$('#mainUnSign').hide();
					$('#mainYiSign').hide();
					$('#selectMore').hide();
					$('#selectMoreWeiqian').show();
		

					for (var i = 0; i < weiqiandao.length; i++) {
						$(' #xiugaiWeiQianStateValue'+i).attr('src','../../icon/checkbutton_unselectd.png');
					}

					if (tmpSelectPersonWei.length > 0) {
						for (var i = 0; i < tmpSelectPersonWei.length; i++) {
							$(' #xiugaiWeiQianStateValue'+tmpSelectPersonWei[i]).attr('src','../../icon/checkbutton_selectd.png');
						}
					}
					// alert("前"+JSON.stringify(tmpSelectPerson));

				}else{                   //编辑选中被点了
					// $('#rightBtn').text("多选");
					isSelectMore = 0;
					// alert("左边取消多选了");
					if (tmpSelectPersonWei.length > 0) {
						mui('#signState1').popover('toggle');
					}else{
                        ShowToast("请先选择学生");
					}
					
					// alert("后"+JSON.stringify(tmpSelectPerson));

				}
            }
		}else{
			if (haveNoDataYiqian == 1) {
				if (isSelectMore == 0) {   //右边已签到被点了
				$('#rightBtn').text("修改状态");  //多选被点了
					isSelectMore = 1;
					// alert("右边多选了");
	                $('#mainUnSign').hide();
					$('#mainYiSign').hide();
					$('#selectMore').show();
					$('#selectMoreWeiqian').hide();
					// tmpSelectPerson = [];
					for (var i = 0; i < yiqiandao.length; i++) {
						$('body #selectMoreYiqianMain #xiugaiYiQianStateValue'+i).attr('src','../../icon/checkbutton_unselectd.png');
					}
					
					// for (var i = 0; i < weiqiandao.length; i++) {
					// 	$('body  #selectMoreWeiqianMain #xiugaiWeiQianStateValue'+i).attr('src','../../icon/checkbutton_unselectd.png');
					// }
					if (tmpSelectPersonYi.length > 0) {
						for (var i = 0; i < tmpSelectPersonYi.length; i++) {
							$('body  #selectMoreYiqianMain #xiugaiYiQianStateValue'+tmpSelectPersonYi[i]).attr('src','../../icon/checkbutton_selectd.png');
						}
					}
				}else{
					//$('#rightBtn').text("多选");   //编辑选中被点了
					isSelectMore = 0;
					// alert("右边取消多选了");
	                // $('#mainUnSign').hide();
					// $('#mainYiSign').show();
					// $('#selectMore').hide();
	                
					if (tmpSelectPersonYi.length > 0) {
						mui('#signState2').popover('toggle');
					}else{
                        ShowToast("请先选择学生");
					}

				}
			}
            
		}



		
	}
    function ItemTypePoPu1() {
			mui('body').on('tap', '.signState1 .mui-popover-action li>a', function() {
				var typeid = $(this).attr('typeid');
				var tmpArrStr = '';
	            for (var i = 0; i < tmpSelectPersonWei.length; i++) {
	            	var index = tmpSelectPersonWei[i];
	            	tmpArrStr += ''+index+',';
	            }
                tmpArrStr = tmpArrStr.split(',');
		    	tmpArrStr.pop();//删除最后一个元素（最后一个元素为空字符串）
		    	tmpArrStr = tmpArrStr.toString();
                if (tmpArrStr == '') {
                	ShowToast("请先选择学生");
                }else{
                	if (typeid == '1') {  //设为缺勤
					xiugaizhuangtaipost(tmpArrStr,3);
				mui('#signState1').popover('toggle');
				} else if (typeid == '2') {//设为事假
					xiugaizhuangtaipost(tmpArrStr,4);
				mui('#signState1').popover('toggle');
				} else if (typeid == '3') {//设为病假
					xiugaizhuangtaipost(tmpArrStr,5);
				mui('#signState1').popover('toggle');
				} else if (typeid == '4') { //设为迟到
					xiugaizhuangtaipost(tmpArrStr,6);
				mui('#signState1').popover('toggle');
				} else if (typeid == '5') {//设为早退
					xiugaizhuangtaipost(tmpArrStr,7);
				mui('#signState1').popover('toggle');
				} else if (typeid == '6') {//设为已签到
					xiugaizhuangtaipost(tmpArrStr,2);
				mui('#signState1').popover('toggle');
				} else if (typeid == '0') {//取消
					mui('#signState1').popover('toggle');
				}

				$('#mainUnSign').show();
				$('#mainYiSign').hide();
				$('#selectMore').hide();
				$('#selectMoreWeiqian').hide();
				$('#rightBtn').text("多选");
                }
				
				
			});
		}
    function ItemTypePoPu2() {
			mui('body').on('tap', '.signState2 .mui-popover-action li>a', function() {
				var typeid = $(this).attr('typeid');
				var tmpArrStr = '';
                for (var i = 0; i < tmpSelectPersonYi.length; i++) {
	            	var index = tmpSelectPersonYi[i];
	            	tmpArrStr += ''+index+',';
	            }
                tmpArrStr = tmpArrStr.split(',');
		    	tmpArrStr.pop();//删除最后一个元素（最后一个元素为空字符串）
		    	tmpArrStr = tmpArrStr.toString();
                if (tmpArrStr == '') {
                	ShowToast("请先选择学生");
                }else{
                	if (typeid == '1') {  //设为缺勤
					xiugaizhuangtaipost2(tmpArrStr,3);
				mui('#signState2').popover('toggle');
				} else if (typeid == '2') {//设为事假
					xiugaizhuangtaipost2(tmpArrStr,4);
				mui('#signState2').popover('toggle');
				} else if (typeid == '3') {//设为病假
					xiugaizhuangtaipost2(tmpArrStr,5);
				mui('#signState2').popover('toggle');
				} else if (typeid == '4') { //设为迟到
					xiugaizhuangtaipost2(tmpArrStr,6);
				mui('#signState2').popover('toggle');
				} else if (typeid == '5') {//设为早退
					xiugaizhuangtaipost2(tmpArrStr,7);
				mui('#signState2').popover('toggle');
				}  else if (typeid == '0') {//取消
				mui('#signState2').popover('toggle');
				}
				else if (typeid == '6') {//设为未签到
					xiugaizhuangtaipost2(tmpArrStr,1);
					mui('#signState2').popover('toggle');
				}
                $('#mainUnSign').hide();
				$('#mainYiSign').show();
				$('#selectMore').hide();
				$('#selectMoreWeiqian').hide();
				$('#rightBtn').text("多选");
                }
				
			});
		}
		function xiugaizhuangtaipost2(stuArr,index) {
	        var url = url_doSignList;
	        var params = {
	        	iid : api.pageParam.item.id,
	        	stuid : stuArr,
	        	status : index,
	        }
	        showProgress();
	        // alert(JSON.stringify(params));
	        cfnetppPOST(url, params, true, function(data, status) {
	        SendBusinessOperationsLogNotifi('老师批阅学生签到状态', '191', params, params, '', data, '老师批阅学生签到状态接口', '191-01')
                hideProgress();
                if (status == 'success') {
                    $('#noNet').hide();
                    if (data.code == 200) {

                    if (index == 3) {
                    	for (var i = 0; i < tmpSelectPersonYi.length; i++) {
							var rootId = "xiugaiYiQianStateValue"+tmpSelectPersonYi[i];
							$('#'+rootId).text("缺勤");

						}
                    }else if (index == 4) {
                    	for (var i = 0; i < tmpSelectPersonYi.length; i++) {
							var rootId = "xiugaiYiQianStateValue"+tmpSelectPersonYi[i];
							$('#'+rootId).text("事假");

						}
                    }else if (index == 5) {
                    	for (var i = 0; i < tmpSelectPersonYi.length; i++) {
							var rootId = "xiugaiYiQianStateValue"+tmpSelectPersonYi[i];
							$('#'+rootId).text("病假");

						}
                    }else if (index == 6) {
                    	for (var i = 0; i < tmpSelectPersonYi.length; i++) {
							var rootId = "xiugaiYiQianStateValue"+tmpSelectPersonYi[i];
							$('#'+rootId).text("迟到");

						}
                    }else if (index == 7) {
                    	for (var i = 0; i < tmpSelectPersonYi.length; i++) {
							var rootId = "xiugaiYiQianStateValue"+tmpSelectPersonYi[i];
							$('#'+rootId).text("早退");

						}
                    }
                    else if (index == 1) {
                    	for (var i = 0; i < tmpSelectPersonYi.length; i++) {
							var rootId = "xiugaiYiQianStateValue"+tmpSelectPersonYi[i];
							$('#'+rootId).text("未签到");

						}
                    }
                    loadSignedStates();
                    tmpSelectPersonYi = [];

                    }else if(data.code == 108){
                       api.toast({
                            msg : '修改失败',
                            duration : 2000,
                            location : 'bottom'
                        });
                    }else if(data.code == 101){
                       api.toast({
                            msg : '参数错误',
                            duration : 2000,
                            location : 'bottom'
                        });
                    }
                } else {
                    $('#noNet').show();
                }
            });
    }
		function xiugaizhuangtaipost(stuArr,index) {
	        var url = url_doSignList;
	        var params = {
	        	iid : api.pageParam.item.id,
	        	stuid : stuArr,
	        	status : index,
	        }
	        // alert(JSON.stringify(params));
	        showProgress();
	        cfnetppPOST(url, params, true, function(data, status) {
	         SendBusinessOperationsLogNotifi('老师批阅学生签到状态', '191', params, params, '', data, '老师批阅学生签到状态接口', '191-01')
                hideProgress();
                if (status == 'success') {
                    $('#noNet').hide();
                    if (data.code == 200) {

                    if (index == 3) {
                    	for (var i = 0; i < tmpSelectPersonWei.length; i++) {
							var rootId = "xiugaiWeiQianStateValue"+tmpSelectPersonWei[i];
							$('#'+rootId).text("缺勤");

						}
                    }else if (index == 4) {
                    	for (var i = 0; i < tmpSelectPersonWei.length; i++) {
							var rootId = "xiugaiWeiQianStateValue"+tmpSelectPersonWei[i];
							$('#'+rootId).text("事假");

						}
                    }else if (index == 5) {
                    	for (var i = 0; i < tmpSelectPersonWei.length; i++) {
							var rootId = "xiugaiWeiQianStateValue"+tmpSelectPersonWei[i];
							$('#'+rootId).text("病假");

						}
                    }else if (index == 6) {
                    	for (var i = 0; i < tmpSelectPersonWei.length; i++) {
							var rootId = "xiugaiWeiQianStateValue"+tmpSelectPersonWei[i];
							$('#'+rootId).text("迟到");

						}
                    }else if (index == 7) {
                    	for (var i = 0; i < tmpSelectPersonWei.length; i++) {
							var rootId = "xiugaiWeiQianStateValue"+tmpSelectPersonWei[i];
							$('#'+rootId).text("早退");

						}
                    }else if (index == 2) {
                    	for (var i = 0; i < tmpSelectPersonWei.length; i++) {
							var rootId = "xiugaiWeiQianStateValue"+tmpSelectPersonWei[i];
							$('#'+rootId).text("已签到");

						}
                    }
                    loadSignedStates();
                    tmpSelectPersonWei = [];

                    }else if(data.code == 108){
                       api.toast({
                            msg : '修改失败',
                            duration : 2000,
                            location : 'bottom'
                        });
                    }else if(data.code == 101){
                       api.toast({
                            msg : '参数错误',
                            duration : 2000,
                            location : 'bottom'
                        });
                    }
                } else {
                    $('#noNet').show();
                }
            });
    }
    function setupSubframe() {
			var y = $('.base_navigation_bar').height() + 22;
			var h = api.winHeight - y;
			api.openFrame({
				name : 'TeacherSignDetailFrame',
				url : 'TeacherSignDetailFrame.html',
				rect : {
					x : 0,
					y : y,
					w : 'auto',
					h : h
				},
				bounces : false,
				vScrollBarEnabled : true,
				hScrollBarEnabled : false
			});
		}

</script>
</html>